package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice.model.SensoryScore;
import com.sooncode.project.focusservice.service.SensoryScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("sensoryScore")
public class SensoryScoreController {
    @Autowired
    private SensoryScoreService sensoryScoreService;

    @PostMapping("sensoryScore")
    public boolean add(@RequestParam Map<String,Object> map) {
        return sensoryScoreService.add(map);
    }

    @PutMapping("sensoryScore")
    public boolean modify(@RequestParam String id, @RequestParam Map map) {
        return sensoryScoreService.modify(id,map);
    }
    @DeleteMapping("sensoryScore")
    public boolean delete(@RequestParam String[] ids) {
        for(String id:ids)
            sensoryScoreService.delete(id);
        return true;
    }
    @GetMapping("sensoryScores")
    public Page<SensoryScore> getPageList(@RequestParam int pageSize, @RequestParam int pageIndex, @RequestParam Map<String,Object> map) {
        map.remove("pageSize");
        map.remove("pageIndex");
        return sensoryScoreService.getPageList(pageSize,pageIndex-1,map);
    }
    @PostMapping("copy")
    public boolean copy(@RequestParam String id) {
        return sensoryScoreService.copy(id);
    }

}
